<?php
// 本类由系统自动生成，仅供测试用途
namespace Admin\Controller;
use Think\Controller;
class LinkController extends baseActionController {
     public function lists(){
    	$urllink = M("urllink");
    	$arr = $urllink->select();
        $this->assign("arr",$arr);
        $this->display();
    }

     //添加
	public function add(){
		$this->display();
	}
	public function doadd(){
      	$stu = D('urllink');
		if($stu->create()){
			$stu->add();
			$this->success('添加成功',U('link/lists'));
		}else{
			$this->error('添加失败',U('link/lists'));
		}
}
	//删除
	public function del(){
        $urllink = M("urllink");
        $id=I('uid');
        $create=$urllink->delete($id);
        if(false == $urllink->delete()){
            $this->success("删除成功!",U("link/lists"));
        }else{
            $this->error("删除失败!",U("link/lists"));
        }
    }

    //修改
	public function chaxun(){
		$id = I('get.uid');
		$vo = D('urllink')->where(array('id'=>$id))->find();
		 $r = array();
			if($vo){
		 		$r['status']=true;
		 	}else{
		 		$r['status']=false;
			}
		$this->ajaxReturn($vo);
		
	}

	public function doedit(){
		$vo = D('urllink');
		$vo->create($_POST);	
		if($vo->save()){
			$r['msg']='修改成功';
			$r['status']=true;
		}else{
			$r['msg']='修改失败';
			$r['status']=false;
		}
		$this->ajaxReturn($r);	
	}
}